package com.haoze.nurse.dao;

import com.haoze.nurse.dto.NursePatientMsgDTO;
import com.haoze.nurse.dto.PatientCardsDTO;
import com.haoze.nurse.dto.WardOverviewLogDTO;
import com.haoze.nurse.dto.WardSummaryDTO;
import com.haoze.nurse.model.PatientInHospitalEntity;
import com.haoze.nurse.vo.InOrOutHispotal;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

public interface NursePatientMapper {

    /**
     * 查询用户授权科室
     *
     * @param userId
     * @return
     */
    List<Map<String, String>> getDepts(@Param("userId") String userId);

    /**
     * 获取病人基本信息
     *
     * @param inpatNum 住院号
     * @return
     */
    NursePatientMsgDTO getPatientInfo(@Param("inpatNum") String inpatNum);
    List<NursePatientMsgDTO> getPatientInfo1(@Param("inpatNums") String inpatNums);

    /**
     * 获取病人基本信息
     *
     * @param inpatNum 住院号
     * @return
     */
    Map<String, String> queryPatientInfo(@Param("inpatNum") String inpatNum);

    /**
     * 查询病区住院病人
     *
     * @param wardId
     * @param inpatNumSearch
     * @return
     */
    List<Map<String, String>> getNursePatientsInHospital(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName);

    List<Map<String, String>> getNursePatientsInHospitalBySearch(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName);

    List<Map<String, String>> getPatientsInHospitalBySearch(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName);


    List<Map<String, String>> getNursePatientsOutHospital(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("lastMonth") Date lastMonth);
    List<Map<String, String>> getNursePatientsOutHospital2(
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("lastMonth") Date lastMonth);

    List<Map<String, String>> getNursePatientsTrans(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("currTime") Date currTime,
            @Param("leaveTimeLength") Integer leaveTimeLength);

    /**
     * 获取转病区，转科，转床
     *
     * @param nodeTime
     * @param inpatNum
     * @return
     */
    Map<String, String> queryTransRecord(@Param("nodeTime") Date nodeTime,
                                         @Param("inpatNum") String inpatNum);

    /**
     * 保存和编辑护理记录时获取当前科室信息
     *
     * @param inpatNum
     * @return
     */
    Map<String, String> queryDeptInfo(@Param("inpatNum") String inpatNum);

    /**
     * 更新孕次
     *
     * @param pregnancyCount
     * @return
     */
    int updatePregnancyCount(@Param("inpatNum") String inpatNum,
                             @Param("pregnancyCount") String pregnancyCount);

    /**
     * 更新产次
     *
     * @param productionCount
     * @return
     */
    int updateProductionCount(@Param("inpatNum") String inpatNum,
                              @Param("productionCount") String productionCount);

    /**
     * 更新预产期
     *
     * @param expectedDate
     * @return
     */
    int updateExpectedDate(@Param("inpatNum") String inpatNum,
                           @Param("expectedDate") String expectedDate);


    Map<String, Object> getLmpByInpatNum(@Param("inpatNum") String inpatNum);

    Map<String, BigDecimal> getPatientAge(@Param("inpatNum") String inpatNum);

    Integer getBabyNum(@Param("inpatNum")String inpatNum);


    List<Map<String, String>> getNursePatientsCardInHospital(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("page") Integer page,
            @Param("size") Integer size);

    List<Map<String, String>> getNursePatientsCardInHospitalBySearch(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("page") Integer page,
            @Param("size") Integer size);

    List<Map<String, String>> getNursePatientsCardOutHospital(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("lastMonth") Date lastMonth,
            @Param("page") Integer page,
            @Param("size") Integer size);

    List<Map<String, String>> getNursePatientsCardTrans(
            @Param("wardId") String wardId,
            @Param("inpatNumSearch") String inpatNumSearch,
            @Param("userName") String userName,
            @Param("currTime") Date currTime,
            @Param("leaveTimeLength") Integer leaveTimeLength,
            @Param("page") Integer page,
            @Param("size") Integer size);

    String getBloodType(@Param("inpatNum") String inpatNum);

    String queryPatientInHospitalAfter(@Param("inpatNum") String inpatNum,
                                       @Param("beforeDateStr") String beforeDateStr);

    String queryHealthNum(@Param("inpatNum") String inpatNum);

    /**
     * 查询出院或全部病人
     */
    List<Map<String, Object>> queryPatients(PatientCardsDTO cardsDTO);

    String queryBlood(@Param("inpatNum") String inpatNum);

    /**
     * 查询血型 ABOAndRH
     * @param inpatNum
     * @return map key:LAB_REPORT_ITEM_CODE REPORT_RESULT
     */
    List<Map<String, String>> queryBloodABOAndRH(@Param("inpatNum") String inpatNum);

    List<Map<String, String>> getPatientSummary(WardSummaryDTO dto);

    List<Map<String, String>> wardDeptSummaryDetail(WardSummaryDTO dto);

    Map<String, String> getPatientInfoForCard(@Param("wardDeptId") String wardDeptId,@Param("medicalNum") String medicalNum,@Param("bedNo") String bedNo);

    List<WardOverviewLogDTO> queryWardOverviewLogListByWardId(@Param("wardId") String wardId);

    Map<String,String> queryWardTotalNum(@Param("wardId") String wardId,@Param("type") String type,@Param("bedFlag") String bedFlag,@Param("dataTime") String dateTime);
    //Map<String,String> queryWardChildBirthNum(@Param("wardId") String wardId,@Param("dataTime") String dateTime,@Param("inpatNum") String inpatNum);
    Map<String,String> queryWardChildBirthNum(@Param("wardId") String wardId,@Param("dataTime") String dateTime);
    List<Map<String,String>> queryWardOrdersNum(@Param("wardId") String wardId,@Param("dataTime") String dateTime,@Param("inpatNum") String inpatNum);
    List<Map<String,String>> queryAssessmentScaleNum(@Param("wardId") String wardId,@Param("inpatNum") String inpatNum);
    Map<String,String> queryWardRotatingBedNum(@Param("wardId") String wardId,@Param("dataTime") String dateTime,@Param("type") String type);
    Map<String,String> queryPatientTemperatureNum(@Param("inpatNums") String[] inpatNums);
    Map<String,String> queryAllergyNum(@Param("inpatNums") String[] inpatNums);
    Map<String,String> getPatientsWithCriticalValueByInpatNum(@Param("inpatNums") String[] inpatNums);
    Map<String,String> getTomorrowOperationNum(@Param("inpatNums") String[] inpatNums,@Param("dataTime") String dateTime);
    List<Map<String,String>> queryNursingGradeByWardId(@Param("wardId") String wardId);

    String queryDeptCodeByDeptId(@feign.Param("deptId") String deptId);

    PatientInHospitalEntity selectPatientByInpatNum(@feign.Param("inpatNum") String inpatNum);

    List<Map<String,String>> queryNursingGradeByInpatNum(@Param("inpatNums") List<String> inpatNums,
                                                         @Param("dateTime") String dateTime,
                                                         @Param("nursingGradeList") List<String> nursingGradeList);

    List<Map<String, Object>> getOperationArrangement(@Param("wardId") String wardId, @Param("wholeInpatNum") String wholeInpatNum,@Param("startTime") String startTime, @Param("endTime") String endTime);

    List<InOrOutHispotal> queryPatientInHospital(@Param("status") Integer status, @Param("wardDeptId") String wardDeptId);

    List<InOrOutHispotal> queryPatientOutHospital(@Param("status") Integer status,@Param("wardDeptId") String wardDeptId,@Param("startTime") String startTime,@Param("endTime") String endTime);

    String queryPersonCodeByUserId(String userId);
}
